package book;

/**
 * Created with IntelliJ IDEA.
 * Description:书架
 * User: YCKOKO
 * Date: 2022-10-22
 * Time: 16:48
 */
public class BookList {
    //创建图书数组
    public Book[] books = new Book[10];
    //计数器usedSize，存储当前书的个数
    public int usedSize;
    //事先通过构造方法初始化的时候，给数组里预存3本书，usedSize=3
    public BookList(){
        books[0] = new Book("三国演义","罗贯中",89,"小说");
        books[1] = new Book("西游记","吴承恩",74,"小说") ;
        books[2] = new Book("红楼梦","曹雪芹",49,"小说");
        this.usedSize = 3;
    }

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }

    public Book getPos(int pos) {
        return books[pos];
    }

    /**
     * 存储一本书到指定位置
     * @param book
     * @param pos
     */
    public void setBooks(Book book,int pos) {
        books[pos] = book;
    }
}
